from django.db import models
from zdjx_hjhy import utils
from django.contrib.auth.models import User
from DjangoUeditor.models import UEditorField
      
class unit_depart(models.Model):
    name = models.CharField(max_length=128,null=True)
    code = models.CharField(max_length=128,null=True)
    
    unit_type = models.CharField(max_length=5,choices=utils.UNIT_TYPE_CHOICES,default=1) 
   
    staff = models.CharField(max_length=8,null=True)
    address = models.CharField(max_length=256,null=True)
    phone = models.CharField(max_length=64,null=True)
    remark = models.CharField(max_length=512,null=True)
    
    status = models.CharField(max_length=5,choices=utils.DATA_STATUS_CHOICES,default=1) 
    createDate = models.DateTimeField(auto_now_add=True)
    schedunum = models.CharField(max_length=64,null=True)
    
    class Meta:
        db_table = 'unit_depart'

    def __unicode__(self):
        return self.name

class role(models.Model):
    name = models.CharField(max_length=128,null=True)
    parent_id = models.CharField(max_length=64,null=True)
    rights = models.CharField(max_length=256,null=True)
    
    class Meta:
        db_table = 'role'

    def __unicode__(self):
        return self.name
    
class user(models.Model):
    user = models.ForeignKey(User)
    username = models.CharField(max_length=128,null=True)
    password = models.CharField(max_length=64,null=True)
    name = models.CharField(max_length=64,null=True)
    phone = models.CharField(max_length=64,null=True)
    rights = models.CharField(max_length=64,null=True)
    rights_id = models.CharField(max_length=64,null=True)
    last_login = models.DateTimeField(null=True)
    ip = models.CharField(max_length=64,null=True)
    status = models.CharField(max_length=5,choices=utils.ACCOUNT_STATUS_CHOICES,default=0)
    role = models.ForeignKey(role)
    rolename = models.CharField(max_length=64,null=True)
    createDate = models.DateTimeField(auto_now_add=True)
    skin = models.CharField(max_length=64,null=True)
    unit_id = models.IntegerField()
    unitname = models.CharField(max_length=64,null=True)
    teachnum = models.CharField(max_length=64,null=True)
    class Meta:
        db_table = 'user'

    def __unicode__(self):
        return self.username
    
class menu(models.Model):
    name = models.CharField(max_length=128,null=True)
    url = models.CharField(max_length=128,null=True)
    parent_id = models.IntegerField()
    order = models.CharField(max_length=64,null=True)
    icon = models.CharField(max_length=64,null=True)
    type = models.CharField(max_length=64,null=True)
    target = models.CharField(max_length=64,null=True)
        
    class Meta:
        db_table = 'menu'

    def __unicode__(self):
        return self.name

class subitem(models.Model):
    role = models.ForeignKey(role)
    menu = models.ForeignKey(menu)
    type = models.CharField(max_length=64,null=True)
    name = models.CharField(max_length=64,null=True)
    status = models.CharField(max_length=5,choices=utils.SUB_ITEM_STATUS_CHOICES,default=1)
    
    class Meta:
        db_table = 'sub_item'

    def __unicode__(self):
        return self.name
 
 
class News(models.Model):
    user_id = models.IntegerField()
    username = models.CharField(max_length=128)
    createDate = models.DateTimeField(auto_now_add=True)
    title = models.CharField(max_length=64)
    iconimg = models.ImageField(upload_to='news',null=True)
    img = models.ImageField(upload_to='news',null=True)
    content = UEditorField(u'lables',width=600, height=300, toolbars="full", imagePath="", filePath="", upload_settings={"imageMaxSize":1204000},settings={},command=None,blank=True)
    desc = models.CharField(max_length=1024)
    status = models.CharField(max_length=2,choices=utils.DATA_STATUS_CHOICES,null=True,default='1')
    readnum = models.IntegerField(default=0)
    sort = models.IntegerField(default=0)
    
    class Meta:
        db_table = 'news'  
    def __unicode__(self):
        return self.title
    
    
class CoopertionPartner(models.Model):
    user_id = models.IntegerField()
    username = models.CharField(max_length=128)
    createDate = models.DateTimeField(auto_now_add=True)
    name = models.CharField(max_length=64)
    img = models.ImageField(upload_to='partner',null=True)
    desc = models.CharField(max_length=1024)
    status = models.CharField(max_length=2,choices=utils.DATA_STATUS_CHOICES,null=True,default='1')
    href = models.CharField(max_length=128)
    sort = models.IntegerField(default=0)
    
    class Meta:
        db_table = 'coopertion_partner'  
    def __unicode__(self):
        return self.name
    
class WebVisitImg(models.Model):
    user_id = models.IntegerField()
    username = models.CharField(max_length=128)
    createDate = models.DateTimeField(auto_now=True)
    img = models.ImageField(upload_to='webimg',null=True)
    status = models.CharField(max_length=2,choices=utils.DATA_STATUS_CHOICES,null=True,default='1')
    type = models.CharField(max_length=2,choices=utils.WEB_TYPE_IMG_CHOICES,null=True)
    meansure = models.CharField(max_length=64,null=True)
    desc = models.CharField(max_length=256,null=True)
    name = models.CharField(max_length=256,null=True)
    href = models.CharField(max_length=256,null=True)
    sort = models.IntegerField()
    
    class Meta:
        db_table = 'web_visit_img'  
    def __unicode__(self):
        return self.username
     
    
class TemplateText(models.Model):
    user = models.ForeignKey(User)
    username = models.CharField(max_length=64,null=True)
    createDate = models.DateTimeField(auto_now_add=True)
    status = models.CharField(max_length=5,choices=utils.DATA_STATUS_CHOICES,default=1,null=True) 
    
    name = models.CharField(max_length=64)
    type = models.CharField(max_length=2,choices=utils.TEMPLATE_TYPE_CHOICES,null=True)
    
    content = UEditorField(u'lables',width=600, height=300, toolbars="full", imagePath="", filePath="", upload_settings={"imageMaxSize":1204000},settings={},command=None,blank=True)
    
    
    class Meta:
        db_table = 'template_text'
    def __unicode__(self):
        return self.name  

class WebConfig(models.Model):
    title = models.CharField(max_length=128,null=True)
    keywords = models.CharField(max_length=512,null=True)
    description = models.CharField(max_length=512,null=True)
    logoimg = models.ImageField(upload_to='config',null=True)
    wechatimg = models.ImageField(upload_to='config',null=True)
    copyright = models.CharField(max_length=512,null=True)
    icp = models.CharField(max_length=128,null=True)
    address = models.CharField(max_length=512,null=True)
    email = models.CharField(max_length=128,null=True)
    phone = models.CharField(max_length=128,null=True)
    
    service1name = models.CharField(max_length=128,null=True)
    service1phone = models.CharField(max_length=64,null=True)
    
    service2name = models.CharField(max_length=128,null=True)
    service2phone = models.CharField(max_length=64,null=True)
    
    service3name = models.CharField(max_length=128,null=True)
    service3phone = models.CharField(max_length=64,null=True)
     
    class Meta:
        db_table = 'web_config'
    def __unicode__(self):
        return self.name  